package com.eascs.spider.zhaopin;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.eascs.spider.zhaopin.actor.Job51Actor;
import com.eascs.spider.zhaopin.proj.SearchFilter;
import com.eascs.spider.zhaopin.schdule.TaskManager;
import com.eascs.spider.zhaopin.util.PropertiesUtil;

/**
 * 增量更新启动类
 *
 */
public class Start {
	private static Logger logger = LoggerFactory.getLogger(Start.class);
	
	public static void main( String[] args ) throws Exception{
    	TaskManager manager = TaskManager.getInstance();
		List<SearchFilter> list = getFilter();
    	for(SearchFilter filter : list){
    		manager.addFilter(filter);
    	}
    }
	
	public static List<SearchFilter> getFilter(){
		List<SearchFilter> list = new ArrayList<>();
		//2，信贷经理
		try {
			String keywords2 = "银行/信贷/ 客户经理/信贷管理/综合管理/贷款";
			String areas2 = "山西/河北";
			String age2 = "25/40";
			for(String keyword : keywords2.split("/")){
				for(String area : areas2.split("/")){
					SearchFilter filter = new SearchFilter();
					filter.setKeyword(keyword);
					filter.setExpAddress(PropertiesUtil.getAreaString(area));
					filter.setAgeMin(Integer.valueOf(age2.split("/")[0]));
					filter.setAgeMax(Integer.valueOf(age2.split("/")[1]));
					list.add(filter);
				}
			}
		} catch (Exception e) {
			logger.error("信贷经理初始化异常" ,e);
		}
		try {
			//1，城市经理
			String keywords1 = "行长/支行行长/分行公司部总经理/分行公司部副总经理/企业金融部/公司";
			String areas1 = "山西/河北";
			String age1 = "30/45";
			for(String keyword : keywords1.split("/")){
				for(String area : areas1.split("/")){
					SearchFilter filter = new SearchFilter();
					filter.setKeyword(keyword);
					filter.setExpAddress(PropertiesUtil.getAreaString(area));
					filter.setAgeMin(Integer.valueOf(age1.split("/")[0]));
					filter.setAgeMax(Integer.valueOf(age1.split("/")[1]));
					list.add(filter);
				}
			}
		} catch (Exception e) {
			logger.error("城市经理初始化异常" ,e);
		}
		
		
		
		//3，金融总监
		try {
			String keywords3 = "行长/支行行长/分行公司部总经理/分行公司部副总经理/企业金融部/公司业务部";
			List<String> areas3 = PropertiesUtil.getShenghui();
			String age3 = "33/42";
			
			for(String keyword : keywords3.split("/")){
				for(String area : areas3){
					SearchFilter filter = new SearchFilter();
					filter.setKeyword(keyword);
					filter.setExpAddress(area);
					filter.setAgeMin(Integer.valueOf(age3.split("/")[0]));
					filter.setAgeMax(Integer.valueOf(age3.split("/")[1]));
					list.add(filter);
				}
			}
			
		} catch (Exception e) {
			logger.error("金融总监初始化异常" ,e);
		}
		
		//4，风险总监/经理
		try {
			String keywords4 = "授信审批/对公授信/中小企业信贷审批/对公客户经理";
			List<String> areas4 = PropertiesUtil.getShenghui();
			String age4 = "30/40";
			for(String keyword : keywords4.split("/")){
				for(String area : areas4){
					SearchFilter filter = new SearchFilter();
					filter.setKeyword(keyword);
					filter.setExpAddress(area);
					filter.setAgeMin(Integer.valueOf(age4.split("/")[0]));
					filter.setAgeMax(Integer.valueOf(age4.split("/")[1]));
					list.add(filter);
				}
			}
		} catch (Exception e) {
			logger.error("风险总监初始化异常" ,e);
		}
		return list;
	}
	
	public void test() throws Exception{
		//测试是否账号需要验证码
    	Job51Actor job51Actor = new Job51Actor(PropertiesUtil.get51jobCookie(), "厂长", PropertiesUtil.getAreaString("山西"), 30, 40);
        Thread thread = new Thread(job51Actor);
        thread.start();
	}
}
